package com.newsproject.controller;

import com.newsproject.pojo.Result;
import com.newsproject.service.PostService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
@RequestMapping("/post")
@Api("获取新闻资讯内容相关的接口")
public class PostController {

    @Autowired
    private PostService postService;

    @ApiOperation(value = "新闻资讯的全部评论分页展示",notes = "需要传递新闻咨讯的id,页码")
    @GetMapping("/selectComment/{postId}/{pageNum}")
    @ResponseBody
    public Result<Map<String,Object>> selectCommentById(@ApiParam("获取传递的文章的id")@PathVariable("postId") Integer postId,
                                                     @ApiParam("获取传递的页码")@PathVariable("pageNum") Integer pageNum) {
        return postService.getAllCommentByPage(postId,pageNum);
    }

    @ApiOperation(value = "获取用户是否关注作者，点赞新闻，收藏新闻，转发新闻", notes = "需要传第新闻咨询的id")
    @GetMapping("/{postId}")
    @ResponseBody
    public Result<Map<String,Object>> getEssayPage(@ApiParam("获取传递的文章的id")@PathVariable("postId") Integer postId,
                                                    HttpSession session){
        return   postService.getSomeStatus(postId,session);
    }

}
